/*
 * @(#)ProgressRenderer.java
 */
package ui;

import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * Progress renderer
 */
public class ProgressRenderer extends DefaultTableCellRenderer {

    private final JProgressBar b = new JProgressBar(0, 100);

    public ProgressRenderer() {
      super();
      setOpaque(true);
      b.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
    }

    @Override
    public Component getTableCellRendererComponent(final JTable table, final Object value,
          final boolean isSelected, final boolean hasFocus, final int row, final int column) {
      if (column == 2) {
            final Integer i = (Integer)value;
          if (i < 100) {
            b.setValue(i);
          } else {
             b.setValue(100);
          }
          return b;
      }
      super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      return this;
    }
  }
